<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    let p = {
      name: '张三',
      age: 10,
      get info() {
        return this.name + ' ' + this.age;
      }
    }
    console.log(p);
    p.name = "王五"
    //设置属性值
    Reflect.set(p, 'name', '赵六')

    console.log(p.name);
    //反射获取对象的属性值
    console.log(Reflect.get(p, 'name'));

    // console.log(Reflect.get(p, 'name1'));
    // console.log(Reflect.get(2, 'name'));
    let v2 = Reflect.get(p, 'info')//this指向p对象
    console.log(v2);

    let receiver = {
      name: "大黑鱼",
      age: 22
    }
    let v = Reflect.get(p, 'info', receiver)//this指向receiver对象
    console.log(v);



    console.log(Reflect.get(p, 'name'));


  </script>
</body>

</html>